﻿//∥∥∥∥∥∥∥∥∥∥∥∥∥∥ICode.name ;
//
package ICode.name.ui {
	//
	import flash.events.Event ;
	import fl.controls.ComboBox ;
	import fl.events.ComponentEvent ;
	import flash.events.EventDispatcher ;
	//
	public class NavigateComboBox extends ComboBox {
		//
		private var m_stText:String = "" ;
		private var m_nSelIndex:int = -1 ;
		//
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥构造函数
		public function NavigateComboBox() {
			super() ;
			super.editable = true ;
			super.addEventListener(ComponentEvent.ENTER ,enter_obThis );
			super.addEventListener(Event.CHANGE ,change_obThis );
		}
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥输入拦截函数
		private function change_obThis(e:Event ):void {
			if(super.selectedIndex ==-1 || m_nSelIndex == super.selectedIndex){
				e.stopImmediatePropagation() ;
			}else{
				m_stText = super.selectedLabel ;
			}
			m_nSelIndex = super.selectedIndex ;
		}
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥文本覆盖函数
		public override function get text():String{return m_stText } ;
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥Enter处理函数
		private function enter_obThis (e:ComponentEvent ):void {
			m_stText = super.text ;
			var patcher:EventDispatcher = new EventDispatcher(this);
			var bl:Boolean = patcher.dispatchEvent(new Event(Event.CHANGE,true  )) ;
			trace(">>" + bl );
		}
		//∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥∥
	}
}

